package com.wmyg.antifake.controller;

import com.wmyg.antifake.vo.RecordVo;
import com.wmyg.antifake.service.WxRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 王卓逸
 * @program TODO
 * @description TODO
 * @create 2019-05-13
 */
@RestController
@RequestMapping(value = "/record")
public class WxRecordController {

    @Autowired
    WxRecordService wxRecordService;

    @GetMapping(value = "/records")
    public List<RecordVo> getWxRecords(String provisionalId) {
        return wxRecordService.selectWxRecordListByUser(provisionalId);
    }

    @DeleteMapping(value = "/record")
    public String deleteRecord(Integer recordId) {
        wxRecordService.delete(recordId);
        return "success";
    }

    @PutMapping(value = "/collection")
    public Integer collectRecord(Integer recordId) {
        return wxRecordService.addCollection(recordId);
    }

    @DeleteMapping(value = "/collection")
    public String deleteCollection(Integer recordId) {
        wxRecordService.deleteCollection(recordId);
        return "success";
    }

    @GetMapping(value = "/collections")
    public List<RecordVo> getCollections(String provisionalId) {
        return wxRecordService.getCollectionByUser(provisionalId);
    }

}
